package cn.huiyunche.admin.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import cn.huiyunche.base.service.interfaces.SShippingFeeService;
import cn.huiyunche.base.service.model.SShippingFee;
import cn.huiyunche.base.service.vo.PageVo;
import cn.huiyunche.base.service.vo.Result;

/**
 * 运距系数
 * 距离浮动因数Controller
 * @author Administrator
 *
 */
@RequestMapping("/ship")
@Controller
public class SShippingFeeController {

	private static final Logger logger = LoggerFactory.getLogger(SShippingFeeController.class);

	@Autowired
	private SShippingFeeService sShippingFeeService = null;
	
	public SShippingFeeService getSShippingFeeService(){
		return this.sShippingFeeService;
	}
	
	/**
	 * 查询运距系数 距离浮动因数列表
	 * @param page
	 * @param sShippingFee
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public Result<Map<String, Object>> list(PageVo page, SShippingFee sShippingFee){
		Result<Map<String, Object>> result = new Result<Map<String, Object>>(true, null, "数据加载成功");
		logger.info("select shipping fee list params : {}.", JSON.toJSONString(sShippingFee));
		result.setData(this.getSShippingFeeService().list(page, sShippingFee));
		return result;
	}
	
	/**
	 * 更新运距系数
	 * @param sShippingFee
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/updaterate", method = RequestMethod.POST)
	public Result<String> updateRate(SShippingFee sShippingFee){
		logger.info("udpate shipping fee rate params sShippingFee : {}.", JSON.toJSONString(sShippingFee));
		return this.getSShippingFeeService().updateShippingRate(sShippingFee);
	}
	
	/**
	 * 更新距离浮动因数
	 * @param sShippingFee
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/updatesubsidy", method = RequestMethod.POST)
	public Result<String> updateSubsidy(SShippingFee sShippingFee){
		logger.info("udpate shipping fee subsidy params sShippingFee : {}.", JSON.toJSONString(sShippingFee));
		return this.getSShippingFeeService().updateShippingSubsidy(sShippingFee);
	}
	
}
